package com.ui.zhong.webview

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.Modifier
import com.ui.zhong.Constant
import com.ui.zhong.webview.ui.theme.CustomViewSampleTheme

class WebViewActivity : ComponentActivity() {
    private val TAG = "WebViewActivity==>"
    private lateinit var mUrl: String
    private var mTitle = mutableStateOf("")
    private var mNeedRefresh: Boolean = true
    private var mShowActionBar: Boolean = true
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        mUrl = intent.extras?.getString(Constant.WEB_VIEW_ACTIVITY_URL) ?: ""
        mTitle.value = intent.extras?.getString(Constant.WEB_VIEW_ACTIVITY_TITLE) ?: "WebView"
        mNeedRefresh = intent.extras?.getBoolean(Constant.WEB_VIEW_ACTIVITY_NEED_REFRESH) ?: true
        mShowActionBar =
            intent.extras?.getBoolean(Constant.WEB_VIEW_ACTIVITY_SHOW_ACTION_BAR) ?: true


        setContent {
            CustomViewSampleTheme {
                // A surface container using the 'background' color from the theme
                Column(
                    modifier = Modifier
                        .fillMaxWidth()
                        .fillMaxHeight()
                ) {
                    InternalComposeWebView(url = mUrl, webViewTitle = mTitle, mNeedRefresh)
                }
            }
        }
    }
}
